/**********************************************************************************
* CLASS
*		PropertyBar
*
* DESCRIPTION
*		Generate property object, Cover all of the Genesis property.
*	By adding in the Toolbar Object.
*
* REVISION HISTORY
*		Revision 1.0 2008/10/12 Atthaboon S.
*		First Release
*
**********************************************************************************/
var PropertyBar = Class.create({
	
	/****************************************************
	* FUNCTION
	*		initialize
	*
	* DESCRIPTION
	* 		initialize the Property Bar object.
	*
	* ARGUMENTS
	*		description		: 	string for description
	*		width			:	table width
	*
	****************************************************/
	initialize: function(description,width)
  	{
  		this.table = new Element('table', { 'style':'width: '+width+'px;'});
		this.tableBodyObj = new Element('tbody',{});
		// Add Menu
		this.trMenu = new Element('tr',{});
		this.tdMenu = new Element('td',{'colspan':'2','valign':'top','align':"left"});
		this.tdMenu.update(description+' Property');
		
		this.trMenu.appendChild(this.tdMenu);
		this.tableBodyObj.appendChild(this.trMenu);
		
		// Add 
		this.trProperty = new Element('tr',{});
		
		// Left Side Display
		this.tdLeft  = new Element('td',{'valign':'top','align':"left",'width':'50%'});
		this.tableLeft = new Element('table', {'valign':'top','align':"left",'width':'100%'});
		this.tbodyLeft = new Element('tbody',{});
		this.tableLeft.appendChild(this.tbodyLeft);
		this.tdLeft.appendChild(this.tableLeft);
		
		// Right Side Display
		this.tdRight = new Element('td',{'valign':'top','align':"left",'width':'50%'});
		this.tableRight = new Element('table', {'valign':'top','align':"left",'width':'100%'});
		this.tbodyRight = new Element('tbody',{});
		this.tableRight.appendChild(this.tbodyRight);
		this.tdRight.appendChild(this.tableRight);
		
		
		this.trProperty.appendChild(this.tdLeft);
		this.trProperty.appendChild(this.tdRight);
		this.tableBodyObj.appendChild(this.trProperty);
		this.table.appendChild(this.tableBodyObj);
  	},
	
	/****************************************************
	* FUNCTION 
	*		getDomType
	*
	* DESCRIPTION
	* 		Use by Genesis for get Genesis dom Component Type.
	*
	* ARGUMENTS
	*
	****************************************************/
	getDomType : function()
	{
		return "PropertyBar";
	},	
	
	/****************************************************
	* FUNCTION 
	*		getDomObj
	*
	* DESCRIPTION
	* 		Use by Genesis for get Genesis dom Component.
	*
	* ARGUMENTS
	*
	****************************************************/
	getDomObj : function()
	{
		return this.table;
	},
	
	/****************************************************
	* FUNCTION 
	*		addTextBox
	*
	* DESCRIPTION
	* 		Add Text box in table.
	*
	* ARGUMENTS
	*		description		: 	string for description
	*		unit			:	unit of textbox value
	*		char_width		:	text box width
	*		position		:	0 == left
	*						1 == right
	*
	* RETURN
	*		textbox		:	textbox object
	*
	****************************************************/
	addTextBox : function(description,unit,char_width,position)
	{
		var textbox = new Element('input',{'type':'text','size':''+char_width});
		if(position == 0)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			td1.insert(description+'&nbsp;');
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(textbox);
			td2.insert('&nbsp;'+unit);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyLeft.appendChild(tr);
		}
		else if(position == 1)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			td1.insert(description+'&nbsp;');
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(textbox);
			td2.insert('&nbsp;'+unit);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyRight.appendChild(tr);
		}
		return textbox;
	},
	
	/****************************************************
	* FUNCTION 
	*		addTextArea
	*
	* DESCRIPTION
	* 		Add Text box in table.
	*
	* ARGUMENTS
	*		description		: 	string for description
	*		position		:	0 == left
	*						1 == right
	*						2 == all
	*
	* RETURN
	*		textbox		:	textbox object
	*
	****************************************************/
	addTextArea : function(description,unit,position)
	{
		var textarea = new Element('textarea',{});
		if(position == 0)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			td1.insert(description+'&nbsp;');
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(textarea);
			td2.insert('&nbsp;'+unit);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyLeft.appendChild(tr);
		}
		else if(position == 1)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			td1.insert(description+'&nbsp;');
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(textarea);
			td2.insert('&nbsp;'+unit);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyRight.appendChild(tr);
		}
		else if(position == 2)
		{
			
		}
		return textarea;
	},
	
	/****************************************************
	* FUNCTION 
	*		addButton
	*
	* DESCRIPTION
	* 		Add Button in table.
	*
	* ARGUMENTS
	*		description		: 	string for description
	*		position		:	0 == left
	*						1 == right
	*
	* RETURN
	*		button		:	button object
	*
	****************************************************/
	addButton : function(description,position)
	{
		var button = new Element('input',{'type':'button','value' : ''+description});
		if(position == 0)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(button);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyLeft.appendChild(tr);
		}
		else if(position == 1)
		{
			var tr  =  new Element('tr',{});
			var td1 = new Element('td',{'valign':'top','align':"left",'width':'25%'});
			var td2 = new Element('td',{'valign':'top','align':"left",'width':'75%'});
			td2.appendChild(button);
			tr.appendChild(td1);
			tr.appendChild(td2);
			this.tbodyRight.appendChild(tr);
		}
		return button;
	}
});
